#include <iostream>
#include <future>

void add(int a,int b,std::promise<int> &pro)
{
    std::cout << "加法" << "," << std::this_thread::get_id() << '\n';
    pro.set_value(a + b);
}

int main()
{
    std::promise<int> pro;
    std::future<int> fu = pro.get_future();

    std::thread t(add,10,20,std::ref(pro));

    int res = fu.get();
    std::cout << res << "\n";

    t.join();
    return 0;
}
